/**
*	This script replaces a textarea with the name "editor" with CKEDITOR.
*	
*	Depends on:
*		ckeditor.js
*/
$(document).ready(function() {
	CKEDITOR.config.contentsCss = '/static/lib/bootstrap/css/bootstrap.min.css';
	CKEDITOR.plugins.addExternal('engonlinelink', '/static/script/ckeditor/engonlinelink/');
	CKEDITOR.config.extraPlugins = 'engonlinelink';
	CKEDITOR.config.toolbar = [
		{ name: 'document', groups: [ 'mode', 'document' ], items: [ 'Source', '-', 'Templates' ] },
		{ name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
		{ name: 'links', items: [  'engonlinelink', 'Link', 'Unlink' ] },
		{ name: 'insert', items: [ 'Image', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'Iframe', 'Spoiler', 'Youtube' ] },
		'/',
		{ name: 'editing', groups: [ 'find', 'selection'], items: [ 'Find', 'Replace' ] },
		{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
		{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl' ] },
		'/',
		{ name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] },
		{ name: 'colors', items: [ 'TextColor', 'BGColor' ] },
		{ name: 'tools', items: [ 'Maximize', 'ShowBlocks' ] },
		{ name: 'others', items: [ '-' ] },
	];
	CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;
	CKEDITOR.config.shiftEnterMode = CKEDITOR.ENTER_P;
	CKEDITOR.replace('editor');
});